import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息

public class Main2 {
    static String res; //最终结果

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        // 构造迷宫
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = in.nextInt();
            }
        }

        StringBuilder path = new StringBuilder();
        //初始坐标 0,0
        backTrack(arr, 0, 0, path);
        System.out.println(res);
    }

    // 递归回溯
    private static void backTrack(int[][] arr, int x, int y, StringBuilder path) {
        //跃出边界或者点位不为0则返回
        if (x < 0 || x >= arr.length || y < 0 || y >= arr[0].length || arr[x][y] != 0) {
            return;
        }

        //走到了最右下点位
        if (x == arr.length - 1 && y == arr[0].length - 1) {
            path.append("(" + x + "," + y + ")\n");
            res = path.toString();
            return;
        }

        //标记为已走过
        arr[x][y] = 1;
        path.append("(" + x + "," + y + ")\n");

        backTrack(arr, x, y - 1, path); //向左
        backTrack(arr, x, y + 1, path); //向右
        backTrack(arr, x - 1, y, path); //向上
        backTrack(arr, x + 1, y, path); //向下

        //回退
        path.delete(path.length() - 6, path.length());
        arr[x][y] = 0;
    }

}

